package com.dianping.cat.consumer.problem.model.transform;
import com.dianping.cat.consumer.problem.model.entity.Duration;
import com.dianping.cat.consumer.problem.model.entity.Entity;
import com.dianping.cat.consumer.problem.model.entity.Entry;
import com.dianping.cat.consumer.problem.model.entity.GraphTrend;
import com.dianping.cat.consumer.problem.model.entity.JavaThread;
import com.dianping.cat.consumer.problem.model.entity.Machine;
import com.dianping.cat.consumer.problem.model.entity.ProblemReport;
import com.dianping.cat.consumer.problem.model.entity.Segment;
import java.util.ArrayList;
import java.util.List;

public class DefaultLinker implements ILinker {
  private boolean m_deferrable;

  public DefaultLinker(boolean deferrable) {
/*  17 */     this.m_deferedJobs = new ArrayList();


    this.m_deferrable = deferrable;
  }
  private List<Runnable> m_deferedJobs;
  public void finish() {
    for (Runnable job : this.m_deferedJobs) {
      job.run();
    }
  }


  public boolean onDuration(final Entry parent, final Duration duration) {
    if (this.m_deferrable) {
      this.m_deferedJobs.add(new Runnable()
          {
            public void run() {
/*  35 */               parent.addDuration(duration);
            }
          });
    } else {
/*  39 */       parent.addDuration(duration);
    }

/*  42 */     return true;
  }


  public boolean onDuration(final Entity parent, final Duration duration) {
/*  47 */     if (this.m_deferrable) {
/*  48 */       this.m_deferedJobs.add(new Runnable()
          {
            public void run() {
/*  51 */               parent.addDuration(duration);
            }
          });
    } else {
/*  55 */       parent.addDuration(duration);
    }

/*  58 */     return true;
  }


  public boolean onEntity(final Machine parent, final Entity entity) {
/*  63 */     if (this.m_deferrable) {
/*  64 */       this.m_deferedJobs.add(new Runnable()
          {
            public void run() {
/*  67 */               parent.addEntity(entity);
            }
          });
    } else {
/*  71 */       parent.addEntity(entity);
    }

/*  74 */     return true;
  }


  public boolean onEntry(Machine parent, Entry entry) {
/*  79 */     parent.addEntry(entry);
/*  80 */     return true;
  }


  public boolean onGraphTrend(Entity parent, GraphTrend graphTrend) {
/*  85 */     parent.setGraphTrend(graphTrend);
/*  86 */     return true;
  }


  public boolean onMachine(final ProblemReport parent, final Machine machine) {
/*  91 */     if (this.m_deferrable) {
/*  92 */       this.m_deferedJobs.add(new Runnable()
          {
            public void run() {
/*  95 */               parent.addMachine(machine);
            }
          });
    } else {
/*  99 */       parent.addMachine(machine);
    }

/* 102 */     return true;
  }


  public boolean onSegment(final JavaThread parent, final Segment segment) {
/* 107 */     if (this.m_deferrable) {
/* 108 */       this.m_deferedJobs.add(new Runnable()
          {
            public void run() {
/* 111 */               parent.addSegment(segment);
            }
          });
    } else {
/* 115 */       parent.addSegment(segment);
    }

/* 118 */     return true;
  }


  public boolean onThread(final Entry parent, final JavaThread thread) {
/* 123 */     if (this.m_deferrable) {
/* 124 */       this.m_deferedJobs.add(new Runnable()
          {
            public void run() {
/* 127 */               parent.addThread(thread);
            }
          });
    } else {
/* 131 */       parent.addThread(thread);
    }

/* 134 */     return true;
  }


  public boolean onThread(final Entity parent, final JavaThread thread) {
/* 139 */     if (this.m_deferrable) {
/* 140 */       this.m_deferedJobs.add(new Runnable()
          {
            public void run() {
/* 143 */               parent.addThread(thread);
            }
          });
    } else {
/* 147 */       parent.addThread(thread);
    }

/* 150 */     return true;
  }
}


/* Location:              /Users/hanfei/Documents/apache-tomcat-9.0.24/webapps/cat/WEB-INF/lib/cat-consumer-3.0.0.jar!/com/dianping/cat/consumer/problem/model/transform/DefaultLinker.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       1.0.7
 */